<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");
	response.setContentType("text/html;charset=UTF-8");
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String path = request.getContextPath();
%>
<html lang="zh-cn">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no, email=no" />
<title>登录</title>
<link rel="stylesheet" href="<%=path %>/admin/css/pintuer.css">
<link rel="stylesheet" href="<%=path %>/admin/css/admin.css">
<script type="text/javascript"> var paths = '<%=path%>'; </script>
<script src="<%=path %>/admin/js/jquery.js"></script>
<script src="<%=path %>/admin/js/pintuer.js"></script>
<script src="<%=path %>/admin/js/pic.js"></script>
<script type="text/javascript" src="<%=path%>/admin/js/lrz.bundle.js"></script>
<script type="text/javascript" src="<%=path%>/admin/js/lrz.all.bundle.js"></script>
<script type="text/javascript" src="<%=path%>/admin/js/1.chunk.js"></script>
<script type="text/javascript" src="<%=path%>/admin/js/2.chunk.js"></script>
<script type="text/javascript" src="<%=path %>/admin/js/admin.js"></script>

</head>
<body>
	<div class="panel admin-panel">
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>认证申请信息 </strong>
		</div>
		<div class="body-content">
			<form id="planForm" method="post" class="form-x" action="<%=path %>/bUserInfo/list">
			<input type="hidden" value="${entity.openid}" name="openid" id="openid"/>
			<input type="hidden" value='${entity.authInfo}' name="jsonInfo" id="jsonInfo"/>
			<c:choose>
                   <c:when test="${authenticationType=='企业'}">
						<div class="form-group">
							<div class="label">
								<label>认证类型：</label>
							</div>
							<div class="field">
								<input type="text" class="input w50 clear" value="" name="type" id="type" />
							</div>
							<div class="label" >
								<label>公司名称：</label>
							</div>
							<div class="field">
								<input type="text" class="input w50 clear" value="" name="name" id="name" />
							</div>
						</div>
						<div class="form-group">
							<div class="label">
								<label>公司地址：</label>
							</div>
							<div class="field" style="width: 65%">
								<input type="text" class="input w50 clear" value="" name="address" id="address" />
							</div>
						</div>
						<div class="form-group">
							<div class="label">
								<label>公司法人：</label>
							</div>
							<div class="field">
								<input type="text" class="input w50 clear" value="" name="legalPerson" id="legalPerson" />
							</div>
							<div class="label">
								<label>公司电话：</label>
							</div>
							<div class="field">
								<input type="text" class="input w50 clear" value="" name="phone" id="phone" />
							</div>
						</div>
						<div class="form-group">
							<div class="label">
								<label>营业执照：</label>
							</div>
							<div class="field">
								<input type="text" class="input w50 clear" value="" name="busNumber" id="busNumber" />
							</div>
						</div>
						<div class="form-group">
							<div class="label">
								<label>法人身份证：</label>
							</div>
							<div class="field" style="min-height: 1px">
								<img src="http://localhost:8080/DRP/static/img/home/1.jpg" style="width:50%" id="idCard" name="idCard">
							    <span><a class="downloadImage" href="javascript:void(0);">下载图片</a></span>
							</div>
							<div class="label">
								<label>营业执照附件：</label>
							</div>
							<div class="field" style="min-height: 1px">
								<img src="http://localhost:8080/DRP/static/img/home/2.png" style="width:50%" id="licenseAttachment" name="licenseAttachment">
							    <span><a class="downloadImage" href="javascript:void(0);">下载图片</a></span>
							</div>
						</div>
					</c:when>
                   <c:otherwise>
                        <div class="form-group">
							<div class="label">
								<label>认证类型：</label>
							</div>
							<div class="field">
								<input type="text" class="input w50 clear" value="" name="type" id="type" />
							</div>
							<div class="label" >
								<label>姓名：</label>
							</div>
							<div class="field">
								<input type="text" class="input w50 clear" value="" name="personName" id="personName" />
							</div>
						</div>
                        <div class="form-group">
							<div class="label">
								<label>身份证号：</label>
							</div>
							<div class="field">
								<input type="text" class="input w50 clear" value="" name="idCardNumber" id="idCardNumber" />
							</div>
							<div class="label" >
								<label>城市：</label>
							</div>
							<div class="field">
								<input type="text" class="input w50 clear" value="" name="city" id="city" />
							</div>
						</div>
						<div class="form-group">
							<div class="label">
								<label>身份证附件：</label>
							</div>
							<div class="field" style="min-height: 1px">
								<img src="http://localhost:8080/DRP/static/img/home/1.jpg" style="width:50%" id="idCard" name="idCard">
							    <span><a class="downloadImage" href="javascript:void(0);">下载图片</a></span>
							</div>
						</div>
                   </c:otherwise>
               </c:choose>
               
               
				<div class="form-group" id="shenhe">
					<div style="text-align:center">
						<button class="button bg-main  authentication1" type="button" state="3">认证通过</button>
						<select class="button bg-main  authentication2" state="2">
							<option value="认证不通过">认证不通过</option>
							<option value="企业名称与营业执照不一致">企业名称与营业执照不一致</option>
							<option value="身份证附件不够清楚">身份证附件不够清楚</option>
							<option value="其他原因">其他原因</option>
						</select>
					</div>
				</div>
			    <div class="form-group" id="bohui">
					<div class="label">
						<label>审核状态：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50 clear" value="" name="yy" id="yy" />
					</div>
				</div>
			    <div class="form-group" id="tongguo">
					<div class="label">
						<label>状态：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50 clear" value="通过"/>
					</div>
				</div>
				
			</form>
		</div>
	</div>
</body>
<script type="text/javascript" src="<%=path%>/static/js/swiper-3.4.2.jquery.min.js"></script>
<script type="text/javascript" src="<%=path%>/admin/js/layer/layer.js" ></script>
<script type="text/javascript">

	$(function(){
		 var http = "<%=path%>/file/getImg.html?saveAddress=";
		$('input').attr("disabled",true);
		 var json = eval('(' + $("#jsonInfo").val() + ')');
		 var type=json["type"];//类型
		 $("#type").val(type);
		 var idCard=json["idCard"];//身份证附件
		 $("#idCard").attr("src",http+idCard);
		 //认证审核信息的回显
		 if(type=="企业"){
			 var name=json["name"];//公司名称
			 $("#name").val(name);
			 var address=json["address"];//公司地址
			 $("#address").val(address);
			 var legalPerson=json["legalPerson"];//公司法人
			 $("#legalPerson").val(legalPerson);
			 var phone=json["phone"];//公司电话
			 $("#phone").val(phone);
			 var busNumber=json["busNumber"];//营业执照号
			 $("#busNumber").val(busNumber);
			 var licenseAttachment=json["licenseAttachment"];//营业执照附件
			 $("#licenseAttachment").attr("src",http+licenseAttachment);
		 }else{
			 var personName=json["personName"];//姓名
			 $("#personName").val(personName);
			 var idCardNumber=json["idCardNumber"];//身份证附件
			 $("#idCardNumber").val(idCardNumber);
			 var city=json["city"];//城市
			 $("#city").val(city);
		 }
		
		 
		 //判断审核状态
		 var state=json["state"];//状态
		 if(state==1){
			 $("#shenhe").show(); 
			 $("#tongguo").hide(); 
			 $("#bohui").hide(); 
			 $("#weirenzheng").hide(); 
		 }else if(state==2){
			 $("#shenhe").hide(); 
			 $("#tongguo").hide(); 
			 $("#bohui").show(); 
			 $("#weirenzheng").hide(); 
			 $("#yy").val(json["reason"]); 
			 
		 }else if(state==3){
			 $("#shenhe").hide(); 
			 $("#tongguo").show(); 
			 $("#bohui").hide();
			 $("#weirenzheng").hide(); 
		 }
		var subTag = '${param.subTag}';
		if(subTag==1){
			layer.msg('操作成功！');
		}else if(subTag== 2){
			layer.msg('系统忙！');
		}
	});
	

    //下载图片
	$(".downloadImage").click(function() {
		var src=$(this).parents("div").find("img").attr("src");
	    var a = $("<a></a>").attr("href", src).attr("download", "img.png").appendTo("body");

	    a[0].click();
	    a.remove();
	});
    
    //认真审核
	$(".authentication1").click(function() {
		var $this=$(this)
		var json = eval('(' + $("#jsonInfo").val() + ')');
		var state=$(this).attr("state");
		var reason=$(this).val();
		 layer.confirm('确认认证通过吗?', {icon: 3, title:'提示'}, function(index){
			 json["state"]=state;
		        json["reason"]=reason;
		        save(json,state);
	    });
		
		 
			
	});
	$(".authentication2").change(function() {
		var json = eval('(' + $("#jsonInfo").val() + ')');
		var state=$(this).attr("state");
		var reason=$(this).val();
		json["state"]=state;
		json["reason"]=reason;
		 layer.confirm('确认认证不通过吗?', {icon: 3, title:'提示'}, function(index){
			 if(reason!="认证不通过"){
		            save(json,state);
		        }
        });
	});
		
	
	function save(json,state) {
		var openid=$("#openid").val();
		$.ajax({
			url : paths + "/bUserInfo/saveInfo",
			type : "POST",
			dataType : "json",
			data : {
				"json" : JSON.stringify(json),
				"openid" : openid,
				"attestationStatus":state
			},
			success : function(data) {
				
				 window.location= history.back();

			},
			error : function(r, s, m) {
			}
		});
		
	}
	

	/**
	 * 根据图片生成画布
	 */
	function convertImageToCanvas(image) {
		var canvas = document.createElement("canvas");
		canvas.width = image.width;
		canvas.height = image.height;
		canvas.getContext("2d").drawImage(image, 0, 0);
		return canvas;
	}
	/**
	 * 下载图片
	 */
	function down() {
		var sampleImage = document.getElementById("ringoImage"), canvas = convertImageToCanvas(sampleImage);
		url = canvas.toDataURL("image/png");//PNG格式
		//以下代码为下载此图片功能
		var triggerDownload = $("#tttt").attr("href", url).attr("download",
				"order-1111111111.png");
		triggerDownload[0].click();
		//	    triggerDownload.remove();
	}

	function LimitTextArea(field) {
		maxlimit = 100;
		if (field.value.length > maxlimit)
			field.value = field.value.substring(0, maxlimit);
	}
	function sub() {

		$("#planForm").submit();

	};

	$(".plantags").change(function() {
		var roleitem = "";
		$("input[name='checkTag']").each(function() {
			if ($(this).prop("checked")) {
				if (roleitem == "") {
					roleitem += $(this).val();
				} else {
					roleitem += "," + $(this).val();
				}
			}
		});
		$("#planTag").val(roleitem);

	});
</script>
</html>